﻿using System;
using System.IO;
using System.Linq;

namespace Terraria.ModLoader.IO
{
	// Token: 0x020002BF RID: 703
	public class BigEndianReader : BinaryReader
	{
		// Token: 0x06001B9B RID: 7067 RVA: 0x00013DCD File Offset: 0x00011FCD
		public BigEndianReader(Stream input) : base(input)
		{
		}

		// Token: 0x06001B9C RID: 7068 RVA: 0x00013DD6 File Offset: 0x00011FD6
		private byte[] ReadBigEndian(int len)
		{
			if (!BitConverter.IsLittleEndian)
			{
				return this.ReadBytes(len);
			}
			return this.ReadBytes(len).Reverse<byte>().ToArray<byte>();
		}

		// Token: 0x06001B9D RID: 7069 RVA: 0x00013DF8 File Offset: 0x00011FF8
		public override short ReadInt16()
		{
			return BitConverter.ToInt16(this.ReadBigEndian(2), 0);
		}

		// Token: 0x06001B9E RID: 7070 RVA: 0x00013E07 File Offset: 0x00012007
		public override ushort ReadUInt16()
		{
			return BitConverter.ToUInt16(this.ReadBigEndian(2), 0);
		}

		// Token: 0x06001B9F RID: 7071 RVA: 0x00013E16 File Offset: 0x00012016
		public override int ReadInt32()
		{
			return BitConverter.ToInt32(this.ReadBigEndian(4), 0);
		}

		// Token: 0x06001BA0 RID: 7072 RVA: 0x00013E25 File Offset: 0x00012025
		public override uint ReadUInt32()
		{
			return BitConverter.ToUInt32(this.ReadBigEndian(4), 0);
		}

		// Token: 0x06001BA1 RID: 7073 RVA: 0x00013E34 File Offset: 0x00012034
		public override long ReadInt64()
		{
			return BitConverter.ToInt64(this.ReadBigEndian(8), 0);
		}

		// Token: 0x06001BA2 RID: 7074 RVA: 0x00013E43 File Offset: 0x00012043
		public override ulong ReadUInt64()
		{
			return BitConverter.ToUInt64(this.ReadBigEndian(8), 0);
		}

		// Token: 0x06001BA3 RID: 7075 RVA: 0x00013E52 File Offset: 0x00012052
		public override float ReadSingle()
		{
			return BitConverter.ToSingle(this.ReadBigEndian(4), 0);
		}

		// Token: 0x06001BA4 RID: 7076 RVA: 0x00013E61 File Offset: 0x00012061
		public override double ReadDouble()
		{
			return BitConverter.ToDouble(this.ReadBigEndian(8), 0);
		}
	}
}
